package java56_5;

import java.util.Scanner;

public class ScoreStat {

	public static void main(String[] args) {
		// 录入5门课成绩，求平均成绩；如果录入是负数，停止并提示错误
		Scanner sc = new Scanner(System.in);
		double sum = 0, avg, score;
		System.out.println("请输入5门课成绩：");
		boolean isError = false;// 假定没有错误
		for (int i = 1; i <= 5; i++) {
			score = sc.nextDouble();
			if (score < 0) {
				System.out.println("您输入错误，不能小于0");
				isError = true;
				break;
			}
			sum += score;
		}
		if (!isError) {
			avg = sum / 5;
			System.out.println("平均分是" + avg + "分");
		}
		// int i = 1;
		// for (; i <= 5; i++) {
		// score = sc.nextDouble();
		// if (score < 0) {
		// System.out.println("您输入错误，不能小于0");
		// break;
		// }
		// sum += score;
		// }
		// if (i == 6) {
		// avg = sum / 5;
		// System.out.println("平均分是" + avg + "分");
		// }
	}
}
